package com.godme.gateway.endpoint;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.godme.gateway.sentinel.CodeEndpointSentinelResource;
import com.godme.service.code.CodeManager;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/code")
public class CodeEndpoint {


    @DubboReference
    CodeManager codeManager;

    @PostMapping("/send/{mail}")
    @SentinelResource(value = "sendCode", fallback = "sendCodeFallback", blockHandler = "sendCodeBlock", fallbackClass = CodeEndpointSentinelResource.class, blockHandlerClass = CodeEndpointSentinelResource.class)
    public boolean sendCode(@PathVariable("mail") String mail){
        return codeManager.sendCode(mail);
    }
}
